{template aljbd:view_header}
<div id="bdw" class="wp cl">
<div class="content">
<h3>{lang aljbd:s65}</h3>
<div>
</div>
<div style="{if $settings['templatepx']['value']}width: 1200px;{else}width: 960px;{/if} height: 600px;" class="main_map" id="mapObj">
</div>
</div>
</div>
{if $settings['templatepx']['value']}
	{template aljbd:footercss}
{/if}
{if $gookey}
<script async defer
		src="https://maps.googleapis.com/maps/api/js?key={$gookey}&signed_in=true"></script>
<script type="text/javascript" charset="utf-8">
    function toggleBounce(event) {
        if (marker.getAnimation() !== null) {
            marker.setAnimation(null);
        } else {
            marker.setAnimation(google.maps.Animation.BOUNCE);
        }
    }
    var marker;
    var map;
    var infowindow;
    {if $bd['x']!=0 && $bd['y']!=0}
    var y = {$bd['x']};
    var x = {$bd['y']};
    {else}
    var x = {$config['x']};
    var y = {$config['y']};
    {/if}
    var contentString = "<div style=\"text-align:center;\">{if $bd['x']!=0&&$bd['y']!=0&&$_GET['op']!=change}<b>{$bd['name']}</b><br />{lang aljbd:s66}{$bd['tel']}<br />{lang aljbd:s67}{$bd['addr']}{else}{lang aljbd:s68}{/if}</div>";
    var confirmString = "<div style=\"text-align:center;\">{lang aljbd:s69}<br><font color=\"red\">{lang aljbd:s70}</font><br><div><a id=\"correctOk\" class=\"mapmark left\"><font color=\"blue\">{lang aljbd:s71}</font></a><a id=\"correctCancel\" class=\"mapmark right\">&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"blue\">{lang aljbd:s72}</font></a></div></div>";

    map = new google.maps.Map(document.getElementById('mapObj'), {
        zoom: 13,
        center: {lat: x, lng: y}
    });

    marker = new google.maps.Marker({
        map: map,
        draggable: true,
        animation: google.maps.Animation.DROP,
        position: {lat: x, lng: y}
    });

    infowindow = new google.maps.InfoWindow({
        content: contentString,
        position: MouseEvent.latLng,
    });
    infowindow.open(marker.get('map'), marker);
    marker.addListener('click', toggleBounce);
    google.maps.event.addListener(marker, 'dragend', function(MouseEvent) {
        infowindow.close();
        infowindow = new google.maps.InfoWindow({
            content: confirmString,
            position: MouseEvent.latLng,
        });
        infowindow.open(marker.get('map'), marker);
        google.maps.event.addListener(infowindow,"domready",function(){
            jq("#correctOk").click(function() {
                jq.get('plugin.php?id=aljbd&act=mark&formhash={FORMHASH}&bid=' + {$bd['id']} + '&x='+MouseEvent.latLng.lng()+'&y='+MouseEvent.latLng.lat() , function(data) {
                    infowindow.close();
                    infowindow = new google.maps.InfoWindow({
                        content: contentString,
                        position: MouseEvent.latLng,
                    });
                    infowindow.open(marker.get('map'), marker);
                });
            });
            jq("#correctCancel").click(function() {
                infowindow.close();
            });
        });

    });
</script>
{else}
<script src="https://api.map.baidu.com/api?v=2.0&ak=Mz8y6VOGZv8AbIfQas83nf1B&s=1" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">

var map;
var marker;
var infowindow;
var draggable = false;
var contentString = "<div style=\"text-align:center;\">{if $bd['x']>0&&$bd['y']>0&&$_GET['op']!=change}<b>{$bd['name']}</b><br />{lang aljbd:s66}{$bd['tel']}<br />{lang aljbd:s67}{$bd['addr']}{else}{lang aljbd:s68}{/if}</div>";
var confirmString = "<div style=\"text-align:center;\">{lang aljbd:s69}<br><font color=\"red\">{lang aljbd:s70}</font><br><div><a id=\"correctOk\" class=\"mapmark left\"><font color=\"blue\">{lang aljbd:s71}</font></a><a id=\"correctCancel\" class=\"mapmark right\">&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"blue\">{lang aljbd:s72}</font></a></div></div>";

function initialize() {

var point;
var op = "mark";
var mapapimark = "{if $bd['x']>0&&$bd['y']>0}({$bd['x']}, {$bd['y']}){/if}";
var local = '';

if(mapapimark) {
var mapapimarkaction = true;
point = new BMap.Point({$bd['x']}, {$bd['y']});
} else {
if(!local) {
var defaultmapaction = true;
point = new BMap.Point({$config['x']},{$config['y']});
} else {
var geoaction = true;
}
}
var map = new BMap.Map("mapObj");
map.enableScrollWheelZoom();
map.centerAndZoom(point, 14);
if(mapapimarkaction || (defaultmapaction && (op == 'mark'))) {
marker = new BMap.Marker(point, {title: "{$bd['name']}"});
map.addOverlay(marker);
var opts = {  
width : 250,
title : ''
}
infoWindow = new BMap.InfoWindow(contentString, opts); 
marker.openInfoWindow(infoWindow);
marker.enableDragging();
} else if(geoaction) {
var Geocoder = new BMap.Geocoder();
if(Geocoder) {
Geocoder.getPoint(local, function(point){
if (point) {
map.centerAndZoom(point, 14);
if(op == 'mark') {
marker = new BMap.Marker(point, {title: "{$bd['name']}"});
map.addOverlay(marker);
marker.enableDragging();
var opts = {  
width : 250,
title : ''
}
infoWindow = new BMap.InfoWindow(contentString, opts); 
marker.addEventListener("click", function(e){
marker.openInfoWindow(infoWindow);
});
infoWindow.setContent(contentString);
marker.openInfoWindow(infoWindow);
marker.addEventListener("dragstart", function(e){  
marker.closeInfoWindow();
});
marker.addEventListener("dragend", function(e){
infoWindow.setContent(confirmString);
marker.openInfoWindow(infoWindow);
infoWindow.enableAutoPan();
marker.setAnimation(BMAP_ANIMATION_BOUNCE);
marker.setAnimation(null);
jq("#correctOk").click(function() {
newpoint = "("+e.point.lng + ", " + e.point.lat+")";
jq.get('plugin.php?id=aljbd&act=mark&formhash={FORMHASH}&bid=' + {$bd['id']} + '&x='+e.point.lng+'&y='+e.point.lat , function(data) {
infoWindow.setContent(data);
marker.openInfoWindow(infoWindow);
marker.setAnimation(BMAP_ANIMATION_BOUNCE);
marker.setAnimation(null);
});
});
jq("#correctCancel").click(function() {
map.closeInfoWindow();
});
});
}
} else {
alert("{lang aljbd:s73}");
}
}, "");
}
}
var opts = {  
width : 250,
title : ''
}
infoWindow = new BMap.InfoWindow(contentString, opts); 
marker.addEventListener("click", function(e){
marker.openInfoWindow(infoWindow);
});
infoWindow.setContent(contentString);
marker.openInfoWindow(infoWindow);
marker.addEventListener("dragstart", function(e){  
marker.closeInfoWindow();
});
marker.addEventListener("dragend", function(e){
infoWindow.setContent(confirmString);
marker.openInfoWindow(infoWindow);
infoWindow.enableAutoPan();
marker.setAnimation(BMAP_ANIMATION_BOUNCE);
marker.setAnimation(null);
jq("#correctOk").click(function() {
newpoint = "("+e.point.lng + ", " + e.point.lat+")";
jq.get('plugin.php?id=aljbd&act=mark&formhash={FORMHASH}&bid=' + {$bd['id']} + '&x='+e.point.lng+'&y='+e.point.lat , function(data) {
infoWindow.setContent(data);
marker.openInfoWindow(infoWindow);
marker.setAnimation(BMAP_ANIMATION_BOUNCE);
marker.setAnimation(null);
});
});
jq("#correctCancel").click(function() {
map.closeInfoWindow();
});
});
}
initialize();
</script>
{/if}
<div id="ftw">

{template common/footer}